program drop _all

/* THIS PROGRAM IMPLEMENTS GROWTH REGRESSIONS IN TABLE 8 (cols.1-2)
   NOTE: 
   - All the source and results files are saved at single directory: C:\RESTAT\
   - This program and data were written such that all can be run IC STATA-ver. 10.1. 
*/
  

program define GROWTH
clear all
set more off
set memory 90m
set matsize 800
use C:\RESTAT\data1.dta, replace
log using C:\RESTAT\Tab8_tobit.log, replace                     

                       tsset firm year
                       sort primaryu
                       merge primaryu using C:\RESTAT\export_mysample.dta   
                                        /* contains indicators which industries belong to those 2 SKP=CPA
                                           (Czech Production Activity) classification industry groups with 
                                                    at least 1% (exp1=1)--> 72 industries
                                         */
                       drop _merge

  #delimit ;                
                  

                   keep if growth~=. & FG~=. & ageT~=. & sales~=. & AS~=.& ES~=.& FORdirect~=. &
                          intang~=. & ESgap~=. & gap~=. & solvency~=. ;

                      
 /* DROP YEAR 2000 - THE CZECH EXPORT INFO PROVIDED ONLY UNTIL YR 2000 */
                  
                     drop if year==2000; 

/* RESTRICT SAMPLE TO GIVEN SUB-SAMPLE BEFORE CALCULATING FIRM LEVEL MEANS */
                    display" HIGH EXPORT INDUSTRIES: EXP>=1%";
                    keep if exp1==1;
  

 /* GENERATE FIRM LEVEL MEANS TO CONTROL FOR UNOBSERVED HETEROGENEITY */  
                    sort firm year;            
                    by firm: egen avsales=mean(sales);
                    by firm: egen avsales2=mean(sales2);
                    by firm: egen avESgap=mean(ESgap);
                    by firm: egen avFG=mean(FG);               
                    by firm: egen avageT=mean(ageT);
                    by firm: egen avageT2=mean(ageT2);
                    by firm: egen avAS=mean(AS);
                    by firm: egen avage=mean(age);
                    by firm: egen avage2=mean(age2);
                    by firm: egen avAS_age=mean(AS_age);
                    by firm: egen avES=mean(ES);
                    by firm: egen avFORdirect=mean(FORdirect);
                    by firm: egen avintang=mean(intang);
                    by firm: egen avgap=mean(gap);
                    by firm: egen avsolvency=mean(solvency);
                   
                                                      
                    tsset firm year ;
                 

 
/* Note: when we split sample and drop YR 2000, high corr btw. ES and its mean avES (=0.98)--> avES drop*/

/* ****************** TOBIT: Tab 8 (col.1) - HIGH EXPORT INDUSTRIES (>=1%; exp1=1)********* */
  
                   xi:tobit growth FG STATIC ageT ageT2 sales sales2 AS ES FORdirect intang gap ESgap 
                                    D89 solvency NO_FOR year94-year00 i.primaryu*trend reg1-reg7                                  
                                    konkurz liquidate both OUT_BR 
                                    avFG avageT avageT2 avsales avsales2 avAS avFORdirect avintang 
                                    avgap avESgap avsolvency,ll(-1);


/* ************************************ REPEAT FOR THE LOW EXPORT INDUSTRIES ******************* */

clear;
use C:\RESTAT\data1.dta, replace;

                       tsset firm year;
                       sort primaryu;
                       merge primaryu using C:\RESTAT\export_mysample.dta;   
                                        /* contains indicators which industries belong to those 2 SKP=CPA
                                           (Czech Production Activity) classification industry groups with 
                                                    at least 1% (exp1=1)--> 72 industries
                                         */
                       drop _merge;


/* RESTRICT SAMPLE TO NON-MISSING REGRESSORS */                  

                   keep if growth~=. & FG~=. & ageT~=. & sales~=. & AS~=.& ES~=.& FORdirect~=. &
                          intang~=. & ESgap~=. & gap~=. & solvency~=. ;

                      
 /* DROP YEAR 2000 - THE CZECH EXPORT INFO PROVIDED ONLY UNTIL YR 2000 */
                  
                     drop if year==2000; 

/* RESTRICT SAMPLE TO GIVEN SUB-SAMPLE BEFORE CALCULATING FIRM LEVEL MEANS */
                    display" LOW EXPORT INDUSTRIES: EXP<1%";
                    keep if exp1==.;
  

 /* GENERATE FIRM LEVEL MEANS TO CONTROL FOR UNOBSERVED HETEROGENEITY */  
                    sort firm year;            
                    by firm: egen avsales=mean(sales);
                    by firm: egen avsales2=mean(sales2);
                    by firm: egen avESgap=mean(ESgap);
                    by firm: egen avFG=mean(FG);               
                    by firm: egen avageT=mean(ageT);
                    by firm: egen avageT2=mean(ageT2);
                    by firm: egen avAS=mean(AS);
                    by firm: egen avage=mean(age);
                    by firm: egen avage2=mean(age2);
                    by firm: egen avAS_age=mean(AS_age);
                    by firm: egen avES=mean(ES);
                    by firm: egen avFORdirect=mean(FORdirect);
                    by firm: egen avintang=mean(intang);
                    by firm: egen avgap=mean(gap);
                    by firm: egen avsolvency=mean(solvency);
                   
                                                      
                    tsset firm year ;
                 

/* ****************** TOBIT: Tab 8 (col.2) - LOW EXPORT INDUSTRIES (<1%; exp1=.)********* */

/* Note: NO_FOR dummy must be dropped as LOW EXPORT INDUSTRIES HAVE FOR PRESENCE */

                   xi:tobit growth FG STATIC ageT ageT2 sales sales2 AS ES FORdirect intang gap ESgap 
                                    D89 solvency year94-year00 i.primaryu*trend reg1-reg7                                  
                                    konkurz liquidate both OUT_BR 
                                    avFG avageT avageT2 avsales avsales2 avAS avFORdirect avintang 
                                    avgap avESgap avsolvency,ll(-1);



                 
#delimit cr
log close 
end
